<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>督查任务</title>
    <%@ include file="/WEB-INF/views/modules/commons/head.jsp" %>
    <%--多选css--%>
    <link rel="stylesheet" href="<s:url value="/assets/web/js/multiSelect/css/fselect.css"></s:url>">
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>

    <style>

        /*转成省略号*/
        /*.ui-jqgrid tr.jqgrow td { text-overflow : ellipsis; }*/
        .ui-jqgrid tr.jqgrow td {
            white-space: normal !important;
            height: 35px;
            vertical-align: text-top;
            padding-top: 2px;
        }

        .nav {
            margin-left: 0;
        }

        #gview_gridTable .ui-jqgrid-bdiv {
            max-height: 450px;
        !important;
        }

        .nav > li > a:focus, .nav > li > a:hover {
            text-decoration: none;
            background-color: #33CCFF !important;
        }

        #main-container {
            padding-top: 15px;
            position: relative;
            height: calc(100%);
            margin-left: 17.5%;
            margin-top: 60px;
        }

        .modal-dialog {
            z-index: 9999999;
        }

        @media (min-width: 768px) {
            .modal-content {
                -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
                box-shadow: 0 -2px 20px rgba(0, 0, 0, .5) !important;
            }
        }

        .task-btn1 {
            float: left;
            margin-top: 30px;
            text-align: right;
            margin-left: 10px;
        }

        .task-btn1 > li {
            display: inline-block;
            margin-left: 10px;
            padding: 0 10px;
            width: 85px;
            height: 30px;
            background: #337ab7;
            color: #ffffff;
            border-radius: 5px;
            font-size: 14px;
            text-align: center;
            line-height: 31px;
            cursor: pointer;
        }

        .task-btn2 {
            float: right;
            margin-top: 30px;
            text-align: right;
        }

        .task-btn2 > li {
            display: inline-block;
            margin: 0 5px;
            width: 120px;
            height: 30px;
            background: #337ab7;
            color: #ffffff;
            border-radius: 5px;
            font-size: 14px;
            text-align: center;
            line-height: 31px;
            cursor: pointer;
        }

        td {
            cursor: default;
        }

        #more_show {
            margin: 5px 0px 0px 5px;
        }

        .search-row {
            margin-top: 30px;
            margin-left: 7px !important;
        }
    </style>
</head>
<body class="bgcolor">
<%--上传成功模态框--%>
<div class="shade" style="display: none;"></div>
<div class="warning" style="display: none;">
    <p class="title"><em></em><span class="close">X</span></p>
    <p class="cont"></p>
    <div class="la-square-jelly-box la-3x">
        <div></div>
        <div></div>
    </div>
</div>
<%@ include file="/WEB-INF/views/modules/commons/nav.jsp" %>
<%@ include file="/WEB-INF/views/modules/commons/menu.jsp" %>


<!-- /section:basics/navbar.layout -->
<table></table>
<div class="main-container" id="main-container">


    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="search-project clearfix">
            <ul class="task-btn1">
                <li style="background: #46b8da; display: none" id="allDc">全部督查</li>
                <li style="background: #46b8da; position:relative;  display: none" id="dcdt">督查动态
                    <span id="messageNum" class="badge pull-right reds"
                          style="background-color: #d15b47 !important;
                          margin: 10px 3px;
                          position:absolute;
                          top: -15px;
                          right: -17px;"></span></li>
            </ul>
        </div>
        <%--搜索查询--%>
        <div class="row search-row" style="margin-top: 0px; margin-left: 5px !important;">
            <div class="col-xs-2">
                <input type="text" class="form-control" id="searchWord" placeholder="请输入要搜索的关键词"/>
            </div>
            <div class="col-xs-8" style="right: 40px;">
                <div class="col-xs-1" style="width: 100px">
                    <button class="btn btn-large btn-primary" id="query">搜索</button>
                </div>
                <div class="col-xs-3" style="right: 40px;width: 185px">
                    <select class="form-control" id = "taskResult_select">
                        <option value="">选择任务完成状态</option>
                        <option value="0">未完成</option>
                        <option value="1">已完成</option>
                        <option value="3">已考核</option>
                        <option value="4">超时完成</option>
                    </select>
                </div>
                <div class="col-xs-3" style="right: 60px;width: 285px;">
                    <select class="form-control" id = "taskTimes_select">
                        <option value="">选择任务督查轮数</option>
                    </select>
                </div>
                <div class="col-xs-2" style="right: 70px;width:190px; ">
                    <select class="form-control" id = "year_select">
                        <option value="">选择年份</option>
                        <option value="">全部督查</option>
                        <option value="2019">2019年</option>
                        <option value="2020">2020年</option>
                    </select>
                </div>
                <button class="btn btn-large btn-default clickMe" id="more" style="right: 65px;">更多∨</button>
            </div>
        </div>
        <div>
            <div class="col-xs-12 clearfix">
                <div class="pull-left">
                    <%--<button class="btn btn-sm btn-success" style="display: none" id="create">创建任务</button>--%>
                    <%--<button class="btn btn-sm btn-default" style="display: none" id="edits">查看详情或修改</button>--%>
                </div>
            </div>

            <div id="more_show" class="col-xs-12 clearfix" hidden>
                <div class="pull-left">
                    <button class="btn btn-sm btn-danger" style="display: none" id="delete">撤销任务</button>
                    <button class="btn btn-sm btn-danger" style="display: none" id="restartjob">重新督查</button>
                    <button class="btn btn-sm btn-primary" style="display: none" id="feedback">问题反馈</button>
                    <button class="btn btn-sm btn-primary" id="addProblem">提请协调</button>
                    <button class="btn btn-sm btn-primary" style="display: none" id="createLog">我要督办</button>
                    <button class="btn btn-sm btn-primary" style="display: none" id="createRecord">添加完成情况</button>
                    <button class="btn btn-sm btn-success" style="display: none" id="exportTable">导出督查任务</button>
                    <button class="btn btn-sm btn-warning" style="display: none" id="confirmationSup">确认办结</button>
                    <button class="btn btn-sm btn-warning" style="display: none" id="failureTask">查看失效任务</button>
                    <button class="btn btn-sm btn-primary" id="projectReport">导出项目简报</button>
                    <%--责任单位确认办结--%>
                    <%--<button class="btn btn-sm btn-warning" id="confirmationRes">确认办结</button>--%>
                </div>

            </div>
        </div>
        <div class="main-content-inner">
            <div class="page-content">
                <!-- /section:settings.box -->

                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <!-- jqGrid表格 -->
                        <table id="gridTable"></table>
                        <!-- jqGrid工具类 -->
                        <div id="gridPager"></div>
                        <!-- 查询对话框 -->
                        <div style="display: none;">
                            <div class="row" id="queryDialog"></div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
                <div class="row" style="margin-left: 2px;">
                    * 双击列表可查看详情
                </div>
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>


</div><!-- /.main-container -->
</div>
<!-- footer -->
<script src="<s:url value="/assets/web/js/jquery.min.js?v=2.1.4"></s:url>"></script>
<%--公用js--%>
<script src="<s:url value="/assets/web/js/commo.js"></s:url>"></script>
<link rel="stylesheet" href="<s:url value="/assets/web/css/login/bootstrap.min.css?v=3.3.6"></s:url>">
<script src="<s:url value="/assets/web/js/jqpaginator.min.js"></s:url>"></script>
<script src="<s:url value="/assets/web/js/baseAPI.js"></s:url>"></script>
<%--多选js--%>
<script src="<s:url value="/assets/web/js/multiSelect/js/fselect.js"></s:url>"></script>
<script src="<s:url value="/assets/web/common/bootstrapvalidator/dist/js/bootstrapValidator.js"></s:url>"></script>
<%@ include file="/WEB-INF/views/include/footer.jsp" %>
<!-- dialog -->
<%@ include file="/WEB-INF/views/include/dialog.jsp" %>


<script type="text/javascript">
    //基本路径
    var baseUrl = "<s:url value="/missions"></s:url>/";
    //jqgrid的表格高度
    var height = 320;
    //jqgrid表格行头的中文
    var colNames = [
        '督查事项详情',
        '督查轮次',
        '督查组督查次数',
        '责任单位反馈次数',
        '督查组最后一次操作时间',
        '责任单位最后一次操作时间',
        '逾期天数',
        '计划结束时间',
        '任务结果',
        '任务状态',
        '督查组别',
        '督查组成员',
        '督查组手机号',
        '责任单位',
        '责任单位经办人',
        '经办人手机号',
        '项目名称',
        '任务类别',
        '任务名称',
        '计划开始时间',
        '创建日期',
        '创建时间',
        '节点ID',
        '节点名称',
        '任务时间',
        '开始日期',
        '结束日期',
        '督查单位得分',
        '责任单位得分',
        '节点详情',
        '到期日期',
        '响应时间',
        '责任单位结果',
        '督查组结果',
        '是否反馈攻坚',
        '涉及部门',
        '任务单号'
    ];

    var colModel = [
        {name: 'taskContent', index: 'taskContent', width: 200, editable: true},
        {
            name: 'tasktimes',
            index: 'tasktimes',
            width: 68,
            editable: true,
            formatter: taskTimesFmatter,
            cellattr: colorSet
        },
        {name: 'supervisionNum', index: 'supervisionNum', width: 110, editable: true},
        {name: 'resDeptNum', index: 'resDeptNum', width: 120, editable: true},
        {name: 'supervisionLastTime', index: 'supervisionLastTime', width: 168, editable: true},
        {name: 'resDeptLastTime', index: 'resDeptLastTime', width: 168, editable: true},
        {
            name: 'overdueDays',
            index: 'overdueDays',
            width: 68,
            editable: true,
            formatter: overdueDaysFmatter /*, cellattr: overdueDaysColor*/
        },
        {name: 'planEndDate', index: 'planEndDate', width: 100, editable: true},
        {
            name: 'taskResult',
            index: 'taskResult',
            width: 80,
            editable: true,
            formatter: taskResultFmatter,
            cellattr: addCellAttr1
        },
        {name: 'aaa001', index: 'aaa001', width: 68, editable: true, formatter: aa10Fmatter, cellattr: addCellAttr},
        {name: 'groupType', index: 'groupType', width: 100, editable: true, formatter: groupTypeFmatter},
        {name: 'inspectors', index: 'inspectors', width: 80, editable: true, formatter: inspectorsFmatter},
        {name: 'phones', index: 'phones', width: 110, editable: true, formatter: phonesFmatter},
        {name: 'resDept', index: 'resDept', width: 100, editable: true},
        {name: 'operatorUser', index: 'operatorUser', width: 116, editable: true},
        {name: 'operatorPhone', index: 'operatorPhone', width: 110, editable: true},
        {
            name: 'projectName', index: 'projectName', width: 200, editable: true,
            formatter: function (cellvalue, options, rowObject) {
                var projectName = rowObject.projectName;
                var projectId = rowObject.projectId;
                var url = "/projectManger/queryNode?sysId=" + projectId;
                return '<a href=' + url + ' target="_Self" >' + projectName + '</a>';

            }
        },
        {name: 'taskjobType', index: 'taskjobType', width: 68, editable: true},
        {name: 'taskName', index: 'taskName', width: 200, editable: true},
        {name: 'planStartDate', index: 'planStartDate', width: 100, editable: true},
        {name: 'createDate', index: 'createDate', width: 80, editable: true},
        {name: 'createTime', index: 'createTime', width: 80, editable: true},
        {name: 'nodeId', index: 'nodeId', width: 80, editable: true},
        {name: 'nodeName', index: 'nodeName', width: 200, editable: true},
        {name: 'taskDate', index: 'taskDate', width: 68, editable: true, formatter: taskDateFmatter},
        {name: 'startDate', index: 'startDate', width: 80, editable: true},
        {name: 'endDate', index: 'endDate', width: 80, editable: true},
        {name: 'supervisionScore', index: 'supervisionScore', width: 100, editable: true},
        {name: 'respScore', index: 'respScore', width: 100, editable: true},
        {name: 'taskName', index: 'taskName', width: 200, editable: true},
        {name: 'planEndDate', index: 'planEndDate', width: 80, editable: true},
        {name: 'responseTime', index: 'responseTime', width: 80, editable: true},
        {name: 'respResult', index: 'respResult', width: 100, editable: true, formatter: respResultFmatter},
        {
            name: 'supervisionResult',
            index: 'supervisionResult',
            width: 100,
            editable: true,
            formatter: respResultFmatter
        },
        {
            name: 'isfeedbackToTack',
            index: 'isfeedbackToTack',
            width: 100,
            editable: true,
            formatter: isfeedbackToTackFmatter
        },
        {name: 'involveUnit', index: 'involveUnit', width: 110, editable: true},
        {name: 'sysId', index: 'sysId', width: 160, editable: true, key: true}
    ];
    //jqgrid的具体执行方法
    jqgrid({
        autoScroll: true,
        shrinkToFit: false,
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager",
        onSelectRow: function (rowid, status) {
            rowids = $('#gridTable').jqGrid('getGridParam', 'selarrrow');
        },
        onSelectAll: function (aRowids, status) {
            rowids = $('#gridTable').jqGrid('getGridParam', 'selarrrow');
        },
        gridComplete: function () {
            var rowIds = jQuery("#gridTable").jqGrid('getDataIDs');
            for (var k = 0; k < rowIds.length; k++) {
                var flag = false;
                for (var i = 0; i < rowids.length; i++) {
                    if (rowids[i] == rowIds[k]) {
                        flag = true;
                        continue;
                    }
                }
                if (flag && flag == true) {
                    jQuery("#gridTable").setSelection(rowIds[k], true);
                }
            }
        }
    });

    var rowids = [];//选中行id

    /**
     * 重写Array
     */
    Array.prototype.remove = function (val) {
        var index = this.indexOf(val);
        if (index > -1) {
            this.splice(index, 1);
        }
    };

    /**
     * 重写Array
     */
    Array.prototype.indexOf = function (val) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == val) return i;
        }
        return -1;
    };

    //开启冻结列
    $("#gridTable").jqGrid('setFrozenColumns');
    //加载查询对话框
    // $("#queryDialog").load(getUrl("filter"));

    //重置表单
    function reset() {
        resetForm("#formDialog form");
    }

    var exportData = '';

    //最新搜索
    $("#query").click(function () {
        var url = '/missions';
        var searchWord = $("#searchWord").val();
        //先清空条件,多次调用时查询条件会累加
        $('#gridTable').jqGrid('clearGridData');
        $("#gridTable").jqGrid('setGridParam', {
            url: url,
            datatype: 'json',
            postData: {'searchWord': searchWord}, //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入
    });

    //选择查询年份
    $("#year_select").change(function () {
        var url = '/missions';
        var year = $("#year_select").val();
        //先清空条件,多次调用时查询条件会累加
        $('#gridTable').jqGrid('clearGridData');
        $("#gridTable").jqGrid('setGridParam', {
            url: url,
            datatype: 'json',
            postData: {'createDate': year, 'messageFlag': ''}, //发送数据
        }).trigger("reloadGrid"); //重新载入
    });
    //选择查询督查次数
    $("#taskTimes_select").change(function () {
        var url = '/missions';
        var taskTimes = $("#taskTimes_select").val();
        //先清空条件,多次调用时查询条件会累加
        $('#gridTable').jqGrid('clearGridData');
        $("#gridTable").jqGrid('setGridParam', {
            url: url,
            datatype: 'json',
            postData: {'tasktimes': taskTimes, 'messageFlag': ''}, //发送数据
        }).trigger("reloadGrid"); //重新载入
    });
    //选择查询任务完成情况
    $("#taskResult_select").change(function () {
        var url = '/missions';
        var taskResult = $("#taskResult_select").val();
        //先清空条件,多次调用时查询条件会累加
        $('#gridTable').jqGrid('clearGridData');
        $("#gridTable").jqGrid('setGridParam', {
            url: url,
            datatype: 'json',
            postData: {'messageFlag': '','taskResult': taskResult}, //发送数据
        }).trigger("reloadGrid"); //重新载入
    });

    //督查动态
    $("#dcdt").click(function () {
        var url = '/missions';
        //先清空条件,多次调用时查询条件会累加
        $('#gridTable').jqGrid('clearGridData');
        $("#gridTable").jqGrid('setGridParam', {
            url: url,
            datatype: 'json',
            postData: {'messageFlag': '1'}, //发送数据
        }).trigger("reloadGrid"); //重新载入
    });

    //全部督查
    $("#allDc").click(function () {
        var url = '/missions';
        //先清空条件,多次调用时查询条件会累加
        $('#gridTable').jqGrid('clearGridData');
        $("#gridTable").jqGrid('setGridParam', {
            url: url,
            datatype: 'json',
            postData: {'messageFlag': ''}, //发送数据
        }).trigger("reloadGrid"); //重新载入
    });
    //失效任务
    $("#failureTask").click(function () {
        var url = '/missions';
        //先清空条件,多次调用时查询条件会累加
        $('#gridTable').jqGrid('clearGridData');
        $("#gridTable").jqGrid('setGridParam', {
            url: url,
            datatype: 'json',
            postData: {'valid': "0", 'messageFlag': ''}, //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入
    });
    //具体查询方法
    function query() {
        exportData = $('#formDialog form').serialize();
        seachJqgird("#gridTable", "#formDialog form");
        $("#formDialog").modal('hide');
    }
    //更新操作
    $("#edits").click(function () {
        showEditView();
    });


    // /**催办操作按钮
    //  */
    // $("#createLog").click(function () {
    //     showEditDialog({
    //         tableId: "#gridTable",
    //         dialogTitle: "任务催办",
    //         dialogUrl: getUrl("createTaskLog"),
    //         dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="cuiBanEdit()">提交审核</button>' +
    //             '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
    //             '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
    //         errorTitle: "消息对话框",
    //         errorMutiSelectMessage: '您当前选中多行，请重新选择',
    //         errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
    //         errorOk: '确定'
    //     });
    // });
    // /**
    //  * ---------------------催办记录提交---------------
    //  * */
    // //执行更新操作
    // function cuiBanEdit() {
    //     executeSaveOrUpdate({
    //         formId: "#formDialog form",
    //         dialogId: "#formDialog",
    //         url: getUrl("createTaskLog"),
    //         tableId: "#gridTable",
    //         successMessage: "操作成功",
    //         successTitle: '操作对话框',
    //         //failMessage: '更新失败',
    //         failTitle: '消息对话框'
    //     });
    //     //倒计时
    //     var btn = document.getElementById("submit");
    //     btn.disabled = true;
    //     countdown(5);
    // }

    /**
     * 反馈领导
     */
    $("#feedback").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "问题反馈",
            dialogUrl: getUrl("feedback"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="feedbackLeader()"  >确定</button>' +
                '<!--<button type="button" class="btn btn-pink" onclick="reset()">重置</button>-->' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });


    /**
     * 提请协调（增加问题反馈）
     */
    $("#addProblem").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "提请协调",
            dialogUrl: getUrl("addProblem"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="submitProblem()"  >确定提请协调</button>' +
                '<!--<button type="button" class="btn btn-pink" onclick="reset()">重置</button>-->' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });

    function successFunc() {
        window.location.href = '/missions';
    }


    /**确认办结按钮（督查组）
     */
    $("#confirmationSup").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "确认办结",
            dialogUrl: getUrl("confirmationSup"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="confirmationSupBtn()">提交</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });

    /**确认办结按钮（责任单位）
     */
    $("#confirmationRes").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "确认办结",
            dialogUrl: getUrl("confirmationRes"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="confirmationResBtn()">提交</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });


    /**重新开始
     */
    $("#restartjob").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "重新开始",
            dialogUrl: getUrl("rebuildjob"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="Restartedit()"  >确定</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });

    /**添加完成情况
     */
    $("#createRecord").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "添加完成情况",
            dialogUrl: getUrl("createRespRecord"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="recordEdit()" id="updatebtn" >确定</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });




    /**
     * ---------------------催办记录提交(合并在一起)---------------
     * */
    function addCB() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("createTaskLog"),
            tableId: "#gridTable",
            successMessage: "添加成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
        // //倒计时
        // var btn = document.getElementById("submit");
        // btn.disabled = true
        // countdown(5);
    }

    /**
     * ---------------------添加完成情况(合并在一起)---------------
     * */
    function addWC() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("createRespRecord"),
            tableId: "#gridTable",
            successMessage: "添加成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
        // //倒计时
        // var btn = document.getElementById("submit");
        // btn.disabled = true
        // countdown(5);
    }


    /**
     * ---------------确认办结（督查组）---------------
     * */
    function confirmationSupBtn() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("confirmationSup"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true;
        countdown(5);
    }

    /**
     * ---------------确认办结（责任单位）---------------
     * */
    function confirmationResBtn() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("confirmationRes"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true;
        countdown(5);
    }


    /**
     * --------------完成情况记录提交事件 recordEdit ----------
     */
    function recordEdit() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("createRespRecord"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true;
        countdown(5);
    }

    /**
     *
     * 反馈领导
     */
    function feedbackLeader() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("feedback"),
            tableId: "#gridTable",
            successMessage: "发送成功",
            successTitle: '提示',
            //failMessage: '更新失败',
            failTitle: '提示'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true;
        countdown(5);
    }

    /**
     *
     * 生成问题
     */
    function submitProblem() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("addProblem"),
            tableId: "#gridTable",
            successMessage: "提交成功",
            successTitle: '提示',
            //failMessage: '更新失败',
            failTitle: '提示'
            // after: successFunc()
        });

        var flag = $("#helpInfo_addProblem").val();
        if (flag != "") {
            //延时加载
            window.setTimeout(successFunc, 2000);
        }
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true;
        countdown(5);

        //延时加载
        // window.setTimeout(successFunc, 2000);
    }


    /**
     *-------------------------重新开始督查任务-----------------------
     */
    function Restartedit() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("rebuildjob"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true
        countdown(5);
    }

    //执行更新操作
    function edit() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("edit"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true
        countdown(5);
    }

    //显示编辑对话框
    function showEditView() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "任务详情",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="edit()" id="updatebtn" >确定</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }

    //显示编辑对话框
    function showView() {
        var rowData = $('#gridTable').jqGrid('getGridParam', "selrow");
        loadDialog({
            dialogTitle: '督查任务详情',
            dialogUrl: baseUrl + "readLog/" + rowData,
            dialogFoot: '<button type="button" class="btn btn-default" data-dismiss="modal" id="showDetail" onclick="myClose()">关闭</button>'
        });
    }

    function showDetailView() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "任务详情",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button type="button" class="btn btn-default" data-dismiss="modal" onclick="myClose()">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }


    //删除 撤回
    $("#delete").click(function () {
        //showDeleteView();

        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "任务撤回",
            dialogUrl: getUrl("deletejob"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="deleteJob()" >确定</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });


    /**
     * ------------ 删除撤回 ----------
     */
    function deleteJob() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("deletejob"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true
        countdown(5);
    }


    //显示删除对话框
    function showDeleteView() {
        showDeleteDialog({
            url: getUrl("delete"),
            tableId: "#gridTable",
            confirmTitle: "撤回任务",
            confirmMessage: "撤回任务即使该任务失效，任务依然会留底但不进行，确认撤回?",
            confirmOk: "确定",
            confirmCancel: "取消",
            successMessage: "撤回成功",
            successTitle: "消息对话框",
            // failMessage: "删除失败",
            failTitle: "消息对话框",
            errorTitle: "警告提示框",
            errorMessage: "您当前尚未选中一行，请选择后您需要撤回的任务再试",
            errorOk: "确定"
        });
    }

    //显示创建对话框
    $("#create").click(function () {
        loadDialog({
            dialogTitle: '手动新建任务',
            dialogUrl: getUrl("create"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="create()">确认</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });

    //分类编辑框
    $("#createCla").click(function () {
        loadDialog({
            dialogTitle: '创建对话框',
            dialogUrl: getUrl("createCla"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">添加</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });

    //保存数据
    function create() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("create"),
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            //failMessage: '保存失败',
            failTitle: '消息对话框'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true
        countdown(5);
    }


    function myClose() {
        //督查动态数目
        var userId;
        if ('${user.branchType}' == "4") {
            userId = '${user.groupCode}';
        } else {
            userId = '${user.sysId}';
        }
        $.ajax({
            type: "GET",
            url: "/messageList/queryNum",
            dataType: "json",
            data: {userId: userId},
            success: function (model) {
                if (model.code == "200") {
                    $("#messageNum").html(model.data)
                }
            },
            error: function (model) {
            }
        });
    }

    /**
     * 双击显示
     */
    $("#gridTable").dblclick(function (e) {
        showView();
    });

    /**
     * 导出表头选择
     */
    $("#exportTable").click(function () {
        loadDialog({
            dialogTitle: '导出表',
            dialogUrl: getUrl("formHead"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="exports()">确认</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });


    /**
     * 导出项目简报
     */
    $("#projectReport").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "导出项目简报",
            dialogUrl: getUrl("projectReport"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary" onclick="exportProjectReport()" >确定</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });


    function exports() {
        var exportExcel = $('#formDialog form').serialize();
        var searchWord = $("#searchWord").val();
        var win = confirm("确认导出？");
        if (win == true) {
            var url = "";
            if (!isEmpty(exportData)) {
                url = "/export/exportTaskList?" + exportExcel + "&searchWord=" + searchWord + "&sysIds=" + rowids;
            } else {
                url = "/export/exportTaskList?" + exportExcel + "&sysIds=" + rowids;
            }
            window.open(url);
        }
    }

    //导出项目简报
    function exportProjectReport() {
        url = "/missions/exportProjectReportInWord/" + rowids;
        window.open(url);
        $(this.dialogId).modal('hide');
    }

    $(function () {
        //不同用户显示不通按钮
        var userType = ${user.branchType};
        var userRole = "${user.role}";
        if (userRole == "责任人") {
            //显示（搜索、导出督查任务）
            $("#query").css("display", "inline");
            $("#exportTable").css("display", "inline");
        } else {
            if (userType == "4") {
                //显示（搜索、导出督查任务、我要督办、确认办结、全部督查、督查动态）
                $("#query").css("display", "inline");
                $("#exportTable").css("display", "inline");
                // $("#createLog").css("display", "inline");
                $("#confirmationSup").css("display", "inline");
                $("#allDc").css("display", "inline-block");
                $("#dcdt").css("display", "inline-block");
            }
            if (userType == "1") {
                //显示（搜索、导出督查任务、添加完成情况、全部督查、督查动态）
                $("#query").css("display", "inline");
                $("#exportTable").css("display", "inline");
                // $("#createRecord").css("display", "inline");
                $("#allDc").css("display", "inline-block");
                $("#dcdt").css("display", "inline-block");
            }

            if (userType == "0") {
                //显示（搜索、导出督查任务、添加完成情况、全部督查、督查动态）
                $("#query").css("display", "inline");
                $("#exportTable").css("display", "inline");
                // $("#createRecord").css("display", "inline");
                $("#allDc").css("display", "inline-block");
                $("#dcdt").css("display", "inline-block");
            }
            //管理员菜单
            if (userType == "2") {
                $("#query").css("display", "inline");
                $("#create").css("display", "inline");
                $("#edits").css("display", "inline");
                // $("#createLog").css("display", "inline");
                $("#feedback").css("display", "inline");
                $("#restartjob").css("display", "inline");
                // $("#createRecord").css("display", "inline");
                $("#delete").css("display", "inline");
                $("#exportTable").css("display", "inline");
                $("#failureTask").css("display", "inline");
            }
        }

        //督查动态数目
        var userId;
        if ('${user.branchType}' == "4") {
            userId = '${user.groupCode}';
        } else {
            userId = '${user.sysId}';
        }
        $.ajax({
            type: "GET",
            url: "/messageList/queryNum",
            dataType: "json",
            data: {userId: userId},
            success: function (model) {
                if (model.code == "200") {
                    $("#messageNum").html(model.data)
                }
            },
            error: function (model) {
            }
        });
    });

    function aa10Fmatter(cellvalue, options, rowObject) {
        if (cellvalue == "1") {
            return "有效任务";
        } else if (cellvalue == "0") {
            return "失效任务";
        }
    }
    function groupTypeFmatter(cellvalue, options, rowObject) {
        return slices(cellvalue);
    }

    function inspectorsFmatter(cellvalue, options, rowObject) {
        return slices(cellvalue);
    }

    function phonesFmatter(cellvalue, options, rowObject) {
        return slices(cellvalue);
    }

    function taskResultFmatter(cellvalue) {
        if (cellvalue == '0') {
            return "未完成";
        } else if (cellvalue == '1') {
            return "已完成";
        } else if (cellvalue == '3') {
            return "已考核";
        } else if (cellvalue == '4') {
            return "超时完成";
        }
    }

    function taskDateFmatter(cellvalue) {

        if (cellvalue != null) {
            return cellvalue + "天";
        } else {
            return "--天";
        }
    }

    function respResultFmatter(cellvalue) {
        if (cellvalue == '0') {
            return "认定未完成";
        } else if (cellvalue == '1') {
            return "认定已完成";
        } else {

        }
    }

    function isfeedbackToTackFmatter(cellvalue) {
        if (cellvalue == null) {
            return "未反馈";
        } else if (cellvalue == '0') {
            return "未反馈";
        } else if (cellvalue == '1') {
            return "反馈";
        }
    }

    function taskTimesFmatter(cellvalue) {
        if (cellvalue != null) {
            return "第" + cellvalue + "轮";
        } else {
            return "——";
        }
    }

    function overdueDaysFmatter(cellvalue) {
        if (cellvalue != null) {
            return cellvalue + "天";
        } else {
            return "——";
        }
    }


    function addCellAttr(rowId, val, rawObject, cm, rdata) {
        if (rawObject.aaa001 == "0") {
            return "style='color:#f0ad4e'";
        }
    }

    function addCellAttr1(rowId, val, rawObject, cm, rdata) {
        if (rawObject.aaa001 == "0") {
            if (rawObject.taskResult == "0") {
                return "style='color:red'";
            } else {
                return "style='color:#f0ad4e'";
            }
        } else {
            if (rawObject.taskResult == "0") {
                return "style='color:red'";
            }
        }
    }

    function colorSet(rowId, val, rawObject, cm, rdata) {
        if (rawObject.tasktimes == "1") {
            return "style='color:#337ab7'";
        } else if (rawObject.tasktimes == "2") {
            return "style='color:#f0ad4e'";
        } else if (rawObject.tasktimes == "3") {
            return "style='color:#ff0000'";
        }
    }

    //逾期天数颜色
    /*function overdueDaysColor(rowId, val, rawObject, cm, rdata) {
        return "style='color:red'";
    }*/
    //显示隐藏
    $(function () {
        //显示隐藏
        $(".clickMe").click(function () {
            if ($(this).text() === "更多∨") {
                $("#more_show").show(100);
                $(this).text("收起∧")
            } else if ($(this).text() === "收起∧") {
                $("#more_show").hide(100);
                $(this).text("更多∨");
            }
        });
    });
    var taskCol = '${taskCol}';
    if (taskCol != "") {
        // debugger
        var taskName = '${taskName}';
        debugger
        alert(taskName);
        window.onpageshow = function () {
            var url = '/missions';
            //先清空条件,多次调用时查询条件会累加
            $('#gridTable').jqGrid('clearGridData');
            $("#gridTable").jqGrid('setGridParam', {
                url: url,
                datatype: 'json',
                postData: {'sysId': taskCol}, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        }
    }

    $(function () {
        $.ajax({
            type: "GET",
            url: "/missions/getSupervisionNums",
            dataType: "json",
            data: {},
            success: function (model) {
                if (model.code == "200") {
                    var options =
                        "<option value=\"1\">第一轮督查（" + model.data.num1 + "）</option>\n" +
                        "<option value=\"2\">第二轮督查（" + model.data.num2 + "）</option>\n" +
                        "<option value=\"3\">第三轮督查（" + model.data.num3 + "）</option>";
                    $("#taskTimes_select").append(options)
                }
            },
            error: function (model) {
            }
        });
    })

    function slices(strings) {
        if(strings == undefined || strings == null){
            return;
        }
        return (strings.slice(strings.length - 1) === ',') ? strings.slice(0, -1) : strings;
    }
</script>

</body>
</html>